package com.by.controller;

import com.by.biz.IUserBiz;
import com.by.model.Result;
import com.by.model.User;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

@RestController
public class UserController {

    @Autowired
    private IUserBiz userBiz;

    @RequestMapping("/toList")
    public ModelAndView toList() {
        return new ModelAndView("list");
    }
/*sdafsdgfsd*/

    @RequestMapping("/getPage")
    public Map queryUserByPage(int pageNum, int pageSize, User user) {
        Map map = new HashMap();
        map.put("pageSize", pageSize);
        map.put("pageNum", pageNum);
        map.put("user", user);
        Page page = userBiz.queryLikeUsers(map);
        map.put("page", page);
        map.put("totalPage", page.getPages());
        return map;
    }

    @RequestMapping("/getAll")
    public Result addUser(User user) {
     userBiz.addUser(user);
        return new Result();
    }
}
